package com.situ.b2c.catalog.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.ContextLoader;

import com.situ.b2c.catalog.service.CatalogService;

import com.situ.b2c.pojo.Catalog;


@WebServlet("/CataSelectparentIdServlet")
public class CataSelectparentIdServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
    
	private CatalogService catalogService;
   
	
	
	
	public CataSelectparentIdServlet() {
		ApplicationContext context = ContextLoader.getCurrentWebApplicationContext();
		catalogService= context.getBean(CatalogService.class);
		
	}
	
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		List<Catalog> catalogList = catalogService.selectAll();
		
		request.setAttribute("catalog", catalogList);
		request.getRequestDispatcher("B2Choutai/catalog_add.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
